using System;

namespace XSResearch
{
    public class XRInterface
    {
        private bool isConnected = false;

        public event EventHandler<XRDataEventArgs> DataReceived;
        public event EventHandler DeviceConnected;

        public void ConnectXRDevice()
        {
            // 模拟连接延迟
            System.Threading.Thread.Sleep(1000);
            isConnected = true;
            DeviceConnected?.Invoke(this, EventArgs.Empty);
        }

        public object ReceiveXRData()
        {
            if (!isConnected)
                throw new InvalidOperationException("XR device not connected");

            // 模拟接收数据
            var data = new {
                Timestamp = DateTime.Now,
                SensorData = new { X = 0.1, Y = 0.2, Z = 0.3 }
            };

            DataReceived?.Invoke(this, new XRDataEventArgs(data));
            return data;
        }

        public void SendXRFeedback(string feedback)
        {
            if (!isConnected)
                throw new InvalidOperationException("XR device not connected");

            Console.WriteLine($"Sending XR feedback: {feedback}");
        }
    }

    public class XRDataEventArgs : EventArgs
    {
        public object Data { get; }

        public XRDataEventArgs(object data)
        {
            Data = data;
        }
    }
}